/*
 * @Author: Wanko
 * @Date: 2023-08-17 11:19:06
 * @LastEditors: Wanko
 * @LastEditTime: 2023-08-17 14:08:22
 * @Description:
 */
import Mock from 'mockjs'

// 获取 mock.Random 对象

const Random = Mock.Random

const data = Mock.mock({
  'list|20-60': [
    {
      id: '@increment(1)',
      title: '@ctitle',
      content: '@cparagraph',
      add_time: '@date(yyyy-MM-dd hh:mm:ss)'
    }
  ]
})

// repeat
const data1 = Mock.mock({
  'name|1-3': 'wanko',
  number: 1,
  content: '@cparagraph()',
  id: '@increment()',
  name: '@cname()',
  idCard: '@id()',
  address: '@city()',
  date: '@date()', // 只有年月日
  dateTime: '@date(yyyy-MM-dd hh:mm:ss)'
})
// console.log(data1)

// console.log(data)

const data2 = Mock.mock({
    string:'@ctitle()',
    sentence: '@csentence'
})

console.log(data2)

// 正式接口还没有出来之前  给一些假的接口   模拟ajax请求
Mock.mock('/mock/demo', 'get', function () {
  return {
    code: 0,
    message: '前端获取mockjs 成功',
    // data: {
    //   name: Random.cname(),
    //   id: Random.id(),
    //   date: Random.date(),
    //   url: Random.url(),
    //   image: Random.image('200x100', '#50B347', '#FFF', 'Hello')
    // }
    data: data.list
  }
})
